"""
    外卖管理端页面对象
"""
from selenium.webdriver.common.by import By

from base import base_page


class PageAdminLogin(base_page.BasePage):
    # 实例属性，把用到管理端登录的信息实列化
    def __init__(self):
        super().__init__()  # 调用父类初始化方法，获取 driver
        self.username = (By.CSS_SELECTOR, "input[placeholder='账号']")
        print(self.username)
        self.password = (By.CSS_SELECTOR, "input[placeholder='密码']")
        self.login_btn = (By.CSS_SELECTOR, "button.el-button")  # 改为更通用的选择器
        self.login_name = (By.XPATH,"//div[@class='avatar-wrapper']//div//span")
    # 实例方法，登录页面
    def page_admin_login(self):
        # 输入用户名
        self.base_input_text(self.username,"admin")
        # 输入密码
        self.base_input_text(self.password,"123456")
        # 点击登录
        self.base_click(self.login_btn)
        # 获取登录后的信息
        name = self.base_find_element(self.login_name).text
        # 断言
        try:
            assert name == "管理者"
        except Exception as e:
            self.base_get_screen()



